<!DOCTYPE html>
<html>
<meta charset="utf-8">
<link rel="shortcut icon" href="favicon.ico">
  <link rel="stylesheet" href="../../../static/css/bootstrap.min.css" />
  <link rel="stylesheet" href="../../../static/css/animate.css" />
  <link rel="stylesheet" href="../../../static/css/font-awesome.css" />
  <link rel="stylesheet" href="../../../static/css/style.css" />
  <link rel="stylesheet" href="../../../static/css/plugins/iCheck/custom.css" />
  <link rel="stylesheet" href="../../../static/css/plugins/cropper/cropper.css" />
  <link rel="stylesheet" href="../../../static/js/plugins/layer/laydate/skins/default/laydate.css" />
  <link rel="stylesheet" href="../../../static/css/gg-bootdo.css" />
<head th:include="include :: header"></head>
<body class="gray-bg">
  <div class="wrapper wrapper-content ">
    <div class="row">
      <div class="col-sm-12">
        <div class="ibox-content">
          <div id="jsTree"></div>
        </div>
        <div class="form-group ">
          <div class="col-sm-12 col-sm-offset-12">
            <button type="submit" onclick="loadUser()" class="btn btn-primary">提交</button>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div th:include="include :: footer"></div>
  <script src="../../../static/js/public.js"></script>
  <script src="../../../static/js/jquery.min.js?v=2.1.4"></script>
  <script src="../../../static/js/bootstrap.min.js?v=3.3.6"></script>
  <script src="../../../static/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
  <script src="../../../static/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
  <script
      src="../../../static/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
  <script src="../../../static/js/plugins/validate/jquery.validate.min.js"></script>
  <script src="../../../static/js/plugins/validate/messages_zh.min.js"></script>
  <script src="../../../static/js/plugins/jsTree/jstree.min.js"></script>
  <script src="../../../static/js/plugins/jqTreeGrid/jquery.treegrid.min.js"></script>
  <script src="../../../static/js/plugins/jqTreeGrid/jquery.treegrid.extension.js"></script>
  <script src="../../../static/js/plugins/jqTreeGrid/jquery.treegrid.bootstrap3.js"></script>
  <script src="../../../static/js/plugins/chosen/chosen.jquery.js"></script>
  <script src="../../../static/js/plugins/layer/layer.js"></script>
  <script src="../../../static/js/content.js?v=1.0.0"></script>
  <!--summernote-->
  <script src="../../../static/js/plugins/summernote/summernote.js"></script>
  <script src="../../../static/js/plugins/summernote/summernote-zh-CN.min.js"></script>
  <script src="../../../static/js/ajax-util.js"></script>
  <script type="text/javascript" src="../../../static/js/appjs/sys/user/user.js"></script>
  <script type="text/javascript">
    $(document).ready(function() {
      getTreeData()
    });
    function getTreeData() {
      $.ajax({
        type : "GET",
        url : "http://localhost:8066/sys/user/tree",
        success : function(tree) {
          loadTree(tree);
        }
      });
    }
    function loadTree(tree) {
      $('#jsTree').jstree({
        'core' : {
          'data' : tree
        },
        "plugins" : [ "checkbox" ]
      });
      $('#jsTree').jstree().open_all();
    }
    function loadUser(){
      var userNames,userIds;
      var ref = $('#jsTree').jstree(true); // 获得整个树
      userIds = ref.get_bottom_selected();
      users = ref.get_bottom_checked('true');
      var txt="";
      for(var user in users){
        if(users[user].state.mType=="user"){
          txt=txt+users[user].text+",";
        }
      }
      parent.loadUser(userIds,txt);
      var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
      parent.layer.close(index);
    }
  </script>
</body>
</html>
